package com.finace.money.data;

import com.finace.money.common.Constant;
import com.finace.money.common.util.ParamUtil;
import com.finace.money.data.bean.BaseBean;
import com.finace.money.data.bean.EmptyBean;
import com.finace.money.data.bean.ImageBean;
import com.finace.money.data.http.ApiService;
import com.finace.money.presenter.contract.VerifyCodeContract;
import com.google.gson.JsonObject;

import java.util.TreeMap;
import java.util.stream.Stream;

import io.reactivex.Observable;
import okhttp3.Response;
import okhttp3.ResponseBody;

/**
 * Created by zhangpeng on 2018/1/26.
 */

public class VerifyCodeModel implements VerifyCodeContract.IVerifyCodeModel {

    private ApiService mApiService;

    public VerifyCodeModel(ApiService apiService) {
        this.mApiService = apiService;
    }

    @Override
    public Observable<BaseBean<EmptyBean>> sendCode(String phone, String type) {

        TreeMap<String, String> map = new TreeMap<>();
        map.put("phone",phone);
        map.put("type",type);
        return mApiService.backEmpty(Constant.sendCodeInterface, ParamUtil.getParma(map));
    }

    @Override
    public Observable<BaseBean<ImageBean>> getImageCode() {
        return mApiService.getImageCode(Constant.imageInterface, ParamUtil.getParma(new TreeMap<String, String>()));
    }

}
